import axios from 'axios'

const API_PREFIX = import.meta?.env?.VITE_API_PREFIX || ''

export async function fetchUserProfile() {
  if (API_PREFIX) {
    const res = await axios.get(`${API_PREFIX}/profile`)
    return res.data
  }
  return new Promise(resolve => setTimeout(() => resolve({
    id: 'u1001',
    nickname: 'StarYun',
    avatar: '🧑\u200d⚕️',
    phoneMasked: '138****8888',
    tags: [ { key: 'verified', text: '已认证' }, { key: 'mi', text: '医保已绑' } ],
    memberLevel: '健康会员',
  }), 400))
}

export async function fetchUserReminders() {
  if (API_PREFIX) {
    const res = await axios.get(`${API_PREFIX}/profile/reminders`)
    return res.data
  }
  return new Promise(resolve => setTimeout(() => resolve({
    pendingPayments: 1,
    todayAppointments: 1,
    unreadMessages: 3
  }), 350))
}

export async function fetchQuickServices() {
  if (API_PREFIX) {
    const res = await axios.get(`${API_PREFIX}/profile/services`)
    return res.data
  }
  return [
    { key: '诊疗记录', icon: '📄', path: '/records' },
    { key: '预约记录', icon: '📅', path: '/appointments' },
    { key: '电子发票', icon: '🧾', path: '/invoice' },
    { key: '家庭成员', icon: '👨\u200d👩\u200d👧', path: '/family' },
    { key: '医保服务', icon: '💳', path: '/insurance' },
    { key: '设置', icon: '⚙️', path: '/settings' }
  ]
}

export default {
  fetchUserProfile,
  fetchUserReminders,
  fetchQuickServices
}


